<?php

/**
 * sfGuardUserProfile filter form base class.
 *
 * @package    tsantek-shop
 * @subpackage filter
 * @author     Tomislav Šantek
 * @version    SVN: $Id: sfDoctrineFormFilterGeneratedTemplate.php 29570 2010-05-21 14:49:47Z Kris.Wallsmith $
 */
abstract class BasesfGuardUserProfileFormFilter extends BaseFormFilterDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'user_id'      => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('User'), 'add_empty' => true)),
      'location_id'  => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Location'), 'add_empty' => true)),
      'contact_id'   => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Contact'), 'add_empty' => true)),
      'first_name'   => new sfWidgetFormFilterInput(),
      'last_name'    => new sfWidgetFormFilterInput(),
      'email'        => new sfWidgetFormFilterInput(),
      'validate'     => new sfWidgetFormFilterInput(),
      'user_type'    => new sfWidgetFormChoice(array('choices' => array('' => '', 'person' => 'person', 'firm' => 'firm'))),
      'facebook_uid' => new sfWidgetFormFilterInput(),
      'OIB'          => new sfWidgetFormFilterInput(),
      'company'      => new sfWidgetFormFilterInput(),
      'overdraft'    => new sfWidgetFormChoice(array('choices' => array('' => 'yes or no', 1 => 'yes', 0 => 'no'))),
      'credits'      => new sfWidgetFormFilterInput(),
    ));

    $this->setValidators(array(
      'user_id'      => new sfValidatorDoctrineChoice(array('required' => false, 'model' => $this->getRelatedModelName('User'), 'column' => 'id')),
      'location_id'  => new sfValidatorDoctrineChoice(array('required' => false, 'model' => $this->getRelatedModelName('Location'), 'column' => 'id')),
      'contact_id'   => new sfValidatorDoctrineChoice(array('required' => false, 'model' => $this->getRelatedModelName('Contact'), 'column' => 'id')),
      'first_name'   => new sfValidatorPass(array('required' => false)),
      'last_name'    => new sfValidatorPass(array('required' => false)),
      'email'        => new sfValidatorPass(array('required' => false)),
      'validate'     => new sfValidatorPass(array('required' => false)),
      'user_type'    => new sfValidatorChoice(array('required' => false, 'choices' => array('person' => 'person', 'firm' => 'firm'))),
      'facebook_uid' => new sfValidatorSchemaFilter('text', new sfValidatorInteger(array('required' => false))),
      'OIB'          => new sfValidatorPass(array('required' => false)),
      'company'      => new sfValidatorPass(array('required' => false)),
      'overdraft'    => new sfValidatorChoice(array('required' => false, 'choices' => array('', 1, 0))),
      'credits'      => new sfValidatorSchemaFilter('text', new sfValidatorInteger(array('required' => false))),
    ));

    $this->widgetSchema->setNameFormat('sf_guard_user_profile_filters[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    $this->setupInheritance();

    parent::setup();
  }

  public function getModelName()
  {
    return 'sfGuardUserProfile';
  }

  public function getFields()
  {
    return array(
      'id'           => 'Number',
      'user_id'      => 'ForeignKey',
      'location_id'  => 'ForeignKey',
      'contact_id'   => 'ForeignKey',
      'first_name'   => 'Text',
      'last_name'    => 'Text',
      'email'        => 'Text',
      'validate'     => 'Text',
      'user_type'    => 'Enum',
      'facebook_uid' => 'Number',
      'OIB'          => 'Text',
      'company'      => 'Text',
      'overdraft'    => 'Boolean',
      'credits'      => 'Number',
    );
  }
}
